import socket,sys,traceback

port = 50000
host = "localhost"

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect ((host,port))


data = "x" * 10485760

byteswritten  = 0
while byteswritten < len(data):
	startpos = byteswritten
	endpos = min(byteswritten + 1024,len(data))
	byteswritten += s.send(data[startpos:endpos])
	sys.stdout.write("Wrote %d charactor \r "%byteswritten)
	sys.stdout.flush()

s.shutdown()

print "All data sent "

while True :
	buf = s.recv(1024)
	if not len(buf):
		break
	sys.stdout.write(buf)

